package cn.itcast.bos.web.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.itcast.bos.domain.Noticebill;
import cn.itcast.bos.domain.User;
import cn.itcast.bos.domain.pagebean.PageBean;
import cn.itcast.bos.utils.BosGetSesstionUser;
import cn.itcast.bos.web.action.base.BaseAction;
import cn.itcast.crm.domain.Customer;
import cn.itcast.crm.service.CustomerService;

@Controller
@Scope("prototype")
public class NoticebillAction extends BaseAction<Noticebill>{
	@Resource
	private CustomerService customerService;
	
	private String phone;  //telephone
	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String findByTelephone(){
		Customer customer = customerService.findByTelephone(phone);
		this.writeObjectFastjson(customer, new String[]{"decidedzone_id"});
		return NONE;
	}
	
	//saveNoticebill  根据登录的操作用户执行 保存新单 实现自动分单功能; 
	//自动分单 : 根据客户的登记的地址查相关的定区数据, 定区 关联 取派员 实现 分单
	public String saveNoticebill(){
		User user = BosGetSesstionUser.getBosLoginUser();
		model.setUser(user);  //根据登录的操作用户执行 业务通知单关联当前用户
		noticebillService.save(model);
		return "list";
	}
	
	//NoticebillList
	public String NoticebillList(){
		noticebillService.pageQueryList(pageBean);
		String[] excludes={"staff","workbills","telephone"};
		this.selectwriteObjectFastjson(pageBean, excludes);
		return NONE;
	}
}
